<include file="Public/header" />

    <script type="text/javascript" charset="utf-8" src="/Public/wigets/ueditor1_4_2-utf8-php/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/Public/wigets/ueditor1_4_2-utf8-php/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/Public/wigets/ueditor1_4_2-utf8-php/lang/zh-cn/zh-cn.js"></script>
<style>
</style>
    <div class="container">

      <!-- Main component for a primary marketing message or call to action -->
      <div class="jumbotron">
      <form method="post" class="form-signin" action='{:U("submit")}'>
<input type="hidden" name="id" value="{$r.id}" />
<input type="hidden" name="pic" value="{$r.pic}" />


<div class="input-group mb5" style="margin-top:5px;">
  <span class="input-group-addon" id="basic-addon1">问题</span>
    <!--<textarea class="form-control" name="title" rows="5" required>{$r.title}</textarea>-->
  <input type="text" class="form-control" name="title" value="{$r.title}" placeholder="问题题目" aria-describedby="basic-addon1" required>
</div>
          <div class="input-group mb5" style="margin-top:5px;">
          <span class="input-group-addon">问题类别</span>
          <div class="dropdown">
              <select class="selectpicker" id="category"  name="category">
                  <foreach name="c" item="vo" key="k" >
                    <option value="{$vo.id}" <eq name="r.category" value="$vo.id">selected</eq>>{$vo.cname}</option>
                  </foreach>
              </select>
          </div>
          </div>
          <div class="input-group mb5" style="margin-top:5px;">
              <span class="input-group-addon" >分数</span>
              <input type="text" class="form-control" name="fra" value="{$r.fra}" placeholder="问题分数" aria-describedby="basic-addon1" required>
          </div>
<div class="panel panel-default">
	  <!-- Default panel contents -->
	<div class="panel-heading">图片
	</div>
	<div class="panel-body">
		<label type="button" class="btn btn-default navbar-btn" style="padding:0;">
			<img data-e="icon" style="width:300px;" alt="选择图片" src="{$r.pic}" />
			<input id="pic" name="img" type="file" style="display:none;" accept=".jpg,.gif,.png,.jpeg">
		</label>
		<div class="alert alert-info" role="alert">注：图片非必须。</div>
	</div>
</div>

<div class="input-group mb5" style="margin-top:5px;">
  <span class="input-group-addon" id="basic-addonc">答案1</span>
  <input type="text" class="form-control" name="answer1" value="{$r.answer1}" placeholder="答案1" aria-describedby="basic-addonc" required>
  <span class="input-group-addon">
	<label><input type="radio" name="answer" <eq name="r.answer" value="1">checked</eq>  value=1 required>正确答案</label>
  </span>
</div>
	
<div class="input-group mb5" style="margin-top:5px;">
  <span class="input-group-addon" id="basic-addonb">答案2</span>
  <input type="text" class="form-control" name="answer2" value="{$r.answer2}" placeholder="答案2" aria-describedby="basic-addonb" required>
  <span class="input-group-addon">
	<label><input type="radio" name="answer" <eq name="r.answer" value="2">checked</eq> value=2 required>正确答案</label>
  </span>
</div>
	
<div class="input-group mb5" style="margin-top:5px;">
  <span class="input-group-addon" id="basic-addona">答案3</span>
  <input type="text" class="form-control" name="answer3" value="{$r.answer3}" placeholder="答案3" aria-describedby="basic-addona" >
  <span class="input-group-addon">
	<label><input type="radio" name="answer" <eq name="r.answer" value="3">checked</eq> value=3 required>正确答案</label>
  </span>
</div>

<div class="input-group mb5" style="margin-top:5px;">
  <span class="input-group-addon" id="basic-addon3">答案4</span>
  <input type="text" class="form-control" name="answer4" value="{$r.answer4}" placeholder="答案4" aria-describedby="basic-addona" >
  <span class="input-group-addon">
	<label><input type="radio" name="answer" <eq name="r.answer" value="4">checked</eq> value=4 required>正确答案</label>
  </span>
</div>

<br />
	  <button class="btn btn-success" type="submit">提交</button>
	  </form>
      </div>

    </div> <!-- /container -->
<script>

//添加图片
(function(){
	var uploadurl = '{:U("Admin/upload")}';
	var input_fileupload;
	var progress;
	$('#pic').fileupload({
		url: uploadurl,
		dataType: 'json',
		done: function (e, data) {
			input_fileupload.prop('disabled',false);
			input_fileupload.parent().removeClass('disabled');
			try{
				progress.close();
			}
			catch(e){}
			if(data.result.status==1){
				noty({
					closeWith:['click','hover'],
					text: data.result.info,
					theme: 'relax',
					type:'success'
				});
				/*
				json.body[on_page].em = json.body[on_page].em || [];
				var tmp = {type:'img',src:data.result.img};
				var i = json.body[on_page].em.length;
				json.body[on_page].em.push(tmp);
				//$('#page_list').append(getpages(json.body[i],i));
				addem(json.body[on_page].em[i]);
				//edite(5,'img').set(data.result.img,true);
				*/
				$('input[name=pic]').val(data.result.img);
				$('#pic').parent().find('img').attr('src',data.result.img);
			}
			else{
				noty({
					closeWith:['click','hover'],
					text: data.result.info,
					theme: 'relax',
					type:'error'
				});
			}
		},
		progressall: function (e, data) {
			var pro = parseInt(data.loaded / data.total * 100, 10);
			try{
				progress.$bar.find('.progress-bar').width(pro+"%");
			}
			catch(e){}
		},
		start: function(e, data){
			console.log(input_fileupload);
			input_fileupload = $('#pic');
			input_fileupload.prop('disabled',true);
			input_fileupload.parent().addClass('disabled');
			progress = noty({
				closeWith:null,
				text: '<div class="progress" style="margin-bottom:0;">\
						<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 0%">\
						</div>\
					</div>',
				theme: 'relax',
				type:'information'
			});
		},
		fail: function (e, data){
			//console.log('错误');
			input_fileupload.prop('disabled',false);
			input_fileupload.parent().removeClass('disabled');
			try{
				progress.close();
			}
			catch(e){}
			noty({
				closeWith:['click','hover'],
				text: '网络错误，上传失败',
				theme: 'relax',
				type:'error'
			});
		}
	});
})();
</script>
<include file="public/footer" />